package com.yidu.BusinessParament.mapper;

import com.yidu.BusinessParament.entity.Fund;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * 基金设置持久层接口
 * @Version 1.0
 * @Author zsc
 * @Date 2022/12/5 13:29
 */
@Repository
@Mapper
public interface FundMapper {
    /**
     * 查询基金表
     * @param map map集合
     * @return
     */
    @Select("select * from fund where 1=1 ${strWhere} limit #{page},#{limit}")
    public List<Fund> SelectFund(Map map);

    /**
     * 分页查行数 模糊查询后的行数
     * @param map map集合
     * @return
     */
    @Select("select count(*) from fund where 1=1 ${strWhere}")
    public int SelectFundCount(Map map);

    /**
     * 新增基金数据
     * @param fund 基金对象
     * @return
     */
    @Insert ("insert into fund(fundId,fundName,fundType,fundScale,trustee,custodian,fundNetWorth," +
            "trusteeCostRate,custodianCostRate,foundTime,Remark) values(#{fundId},#{fundName},#{fundType}," +
            "#{fundScale},#{trustee},#{custodian},#{fundNetWorth},#{trusteeCostRate},#{custodianCostRate}," +
            "#{foundTime},#{Remark})")
    public int InsertFund(Fund fund);

    /**
     * 删除基金数据
     * @param fundId 基金Id
     * @return
     */
    public int DeleteFund(List fundId);

    /**
     * 修改基金数据
     * @param fund 基金对象
     * @return
     */
    @Update("update fund set fundName=#{fundName},fundType=#{fundType},fundScale=#{fundScale},trustee=#{trustee}," +
            "custodian=#{custodian},fundNetWorth=#{fundNetWorth},trusteeCostRate=#{trusteeCostRate}," +
            "custodianCostRate=#{custodianCostRate},foundTime=#{foundTime},Remark=#{Remark} where fundId=#{fundId}")
    public int UpdateFund(Fund fund);

}
